{% extends "master.html" %}
{% block subtitle %} - 供应商管理 - 更新供应商{% endblock %}


{% block extCSS %}
<style type="text/css">
    .atmtemplate{
        display : none;
    }

</style>
{% endblock %}

{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[
    var extAtm = [];
    {% for a in obj.attachment %}
        extAtm.push({{a.id}});
    {% endfor %}
    
    $(document).ready(function(){
        $("#provinceID").change(function(){
            provinceChange(this,'#cityID');
        });
    });
        
        
    function toSubmit(){
        var msg = [];
        $(".err").removeClass("err");
        clearMsg();
        
        if(!$("#name").val()){
            msg.push('请填写供应商名称！');
            $("#name").addClass('err');
        }
        
        if(!$("#att").val()){
            msg.push('请填写供应商的联系人！');
            $("#att").addClass('err');
        }
        
        if(!$("#tel").val() && !$("#mobile").val()){
            msg.push('请填写供应商的电话或者手机！');
            $("#tel").addClass('err');
            $("#mobile").addClass('err');
        }
        
        if(msg.length>0){
            alertError(msg);
            return false;
        }else{
            $("form").submit()
        }
    }
    
    function toCancel(){
        redirect_alert("{{MSG_LEAVE_WITHOUT_SAVING}}","{{url_for('bpSpl.view',action='view',id=obj.id)}}")
    }

//]]>
</script>
{% endblock %}


{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpMas.view')}}">基础信息</a></li>
          <li><a href="{{url_for('bpSpl.view')}}">供应商管理</a></li>
          <li class="active">更新供应商</li>
        </ol>
    </div>
    <div class="row">
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><button class="btn btn-primary" onclick="toSubmit()">{{BTN_SUBMIT}}</button></div>
            <div class="btn-group"><button class="btn btn-inverse" onclick="toCancel()">{{BTN_CANCEL}}</button></div>
        </div>
    </div>
    <div class="row">
        <form class="" method='POST' action="{{url_for('bpSpl.view',action='update')}}"  enctype="multipart/form-data">
        <input type="hidden" name="id" value="{{obj.id}}"/>
        <input type="hidden" name="attachment" id="attachment" value="{{obj.attachment|join('|',attribute='id')}}"/>
        <fieldset>
            <legend>供应商详情</legend>
            <div class="col-md-4">
                <div class="control-group">
                    <label class="control-label"><label for="name">系统编号</label></label>
                    <div class="controls"><input type="text" name="no" id="no" value="{{obj.no|f}}" readonly="true"></div>
                </div>
                <div class="control-group">
                    <label class="control-label"><label for="name">供应商名称<span style='color:red'>*</span></label></label>
                    <div class="controls"><input type="text" name="name" id="name" value="{{obj.name|f}}"></div>
                </div>
                <div class="control-group">
                    <label class="control-label"><label for="address">地址</label></label>
                    <div class="controls">
                        {{mymacros.select('provinceID',list=getMaster('Province'),value=obj.provinceID)}}
                        {{mymacros.select('cityID',list=getCity(obj.provinceID),value=obj.cityID,blank_option=False)}}
                        <input name="address" id="address" value="{{obj.address|f}}"/>
                   </div>
                </div>
            </div>      
            <div class="col-md-4">
                <div class="control-group">
                    <label class="control-label"><label for="att">联系人<span style='color:red'>*</span></label></label>
                    <div class="controls"><input type="text" value="{{obj.att|f}}" name="att" id="att"></div>
                </div>
                <div class="control-group">
                    <label class="control-label"><label for="tel">联系电话<span style='color:red'>*</span></label></label>
                    <div class="controls"><input type="text" value="{{obj.tel|f}}" name="tel" id="tel"></div>
                </div>
                <div class="control-group">
                    <label class="control-label"><label for="mobile">手机<span style='color:red'>*</span></label></label>
                    <div class="controls"><input type="text" value="{{obj.mobile|f}}" name="mobile" id="mobile"></div>
                </div>
            </div>
            <div class="col-md-4">
                 <div class="control-group">
                    <label class="control-label"><label for="remark">备注</label></label>
                    <div class="controls"><textarea name="remark" id="remark">{{obj.remark|f}}</textarea></div>
                </div>                
            </div>
            <div class="col-md-12">
                <div class="control-group">
                  <label class="control-label" for="attachment">附件</label>
                  <div class="controls">
                      <ul id="atmul" class="list-unstyled">
                          {% for a in obj.attachment %}
                            <li class="extatm">{{a.name}}&nbsp;<a href="#" onclick="delExtAtm(this,{{a.id}},'attachment','extatm')"><i class="glyphicon glyphicon-minus"></i></a></li>
                          {% endfor %}
                          <li><input type="file" name="atm_10"/><a href="#" onclick="addAtm('atmtemplate','atmmk','#atmul')"><i class="glyphicon glyphicon-plus"></i></a></li>
                          <li class="atmtemplate"><input type="file" name="atm_x"/><a href="#" onclick="delAtm(this,'atmmk')"><i class="glyphicon glyphicon-minus"></i></a></li>
                      </ul>
                  </div>
                </div>    
            </div>
        </fieldset>        
        </form>
    </div>
    
   
</div>
{% endblock %}